package cn.gz3c.uitest.view;

import static android.graphics.Typeface.NORMAL;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.graphics.Typeface;
import android.graphics.Xfermode;
import android.view.MotionEvent;

import com.huawei.hms.audioeditor.sdk.asset.HAEAsset;
import com.huawei.hms.audioeditor.sdk.asset.HAEAudioAsset;
import com.huawei.hms.audioeditor.sdk.bean.HAEAudioVolumeObject;
import com.huawei.hms.audioeditor.sdk.engine.audio.RequestParas;
import com.huawei.hms.audioeditor.sdk.util.SmartLog;
import com.huawei.hms.audioeditor.ui.R.color;
import com.huawei.hms.audioeditor.ui.R.drawable;
import com.huawei.hms.audioeditor.ui.R.string;
import com.huawei.hms.audioeditor.ui.common.utils.d;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import cn.gz3c.uitest.Util;
import cn.gz3c.uitest.viewmodel.EditPreviewViewModel;

@SuppressLint("ViewConstructor")
public class WaveTrackView extends BaseWaveTrackView {
    private Paint fa;
    private Paint ga;
    private Paint ha;
    private Paint ia;
    private Paint ja;
    private Paint ka;
    private Paint la;
    private Bitmap ma;
    private Bitmap na;
    private String oa;
    private Context pa;
    private final List<Float> qa = new ArrayList<>();
    private final boolean[] ra = new boolean[]{false};
    private boolean sa = true;
    private float ta = 0.0F;
    private Path ua;
    private Path va;
    private Paint wa;
    private Mode xa;
    private Xfermode ya;
    private Paint za;
    private Paint Aa;
    private Paint Ba;
    boolean Ca;
    private List<WaveTrackView.a> Da;
    private int Ea;
    private int Fa;

    public WaveTrackView(Activity var1, EditPreviewViewModel var2) {
        super(var1, var2, 2);
        this.xa = Mode.ADD;
        this.Ca = true;
        this.Da = new ArrayList<>();
        this.Ea = this.m() + super.a;
        this.Fa = 0;
        this.pa = var1;
        this.x();
    }

    private float a(HAEAudioVolumeObject var1) {
        WaveTrackView var10000 = this;
        float var2 = (float)var1.getMaxValue();
        int var3 = var1.getVolume();
        return (float)(Math.abs(var10000.getMeasuredHeight()) / 2 * var3) / var2;
    }

    public void x() {
        this.ja = new Paint();
        this.ja.setAntiAlias(true);
        this.ja.setColor(Color.parseColor("#FF0D0326"));
        this.ja.setStyle(Style.FILL_AND_STROKE);
        this.ja.setStrokeWidth(5.0F);
        this.ga = new Paint();
        LinearGradient var1;

        float var2 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(32.0F);
        int var3 = Color.parseColor("#8981F7");
        int var4 = Color.parseColor("#8981F7");
        TileMode var5 = TileMode.CLAMP;
        var1 = new LinearGradient(0.0F, 0.0F, 2.0F, var2, var3, var4, var5);
        this.ga.setShader(var1);
        this.ga.setAntiAlias(true);
        this.ga.setStyle(Style.FILL);
        this.ga.setStrokeWidth(2.0F);
        this.ha = new Paint();
        this.ha.setAntiAlias(true);
        this.ha.setColor(Color.parseColor("#00FFFFFF"));
        this.ha.setStyle(Style.FILL);
        this.ha.setStrokeWidth(3.0F);
        this.fa = new Paint();
        this.fa.setColor(Color.parseColor("#1AFFFFFF"));
        this.fa.setStyle(Style.FILL_AND_STROKE);
        this.fa.setStrokeWidth(5.0F);
        this.ia = new Paint();
        this.ia.setAntiAlias(true);
        this.ia.setStrokeCap(Cap.ROUND);
        this.ia.setColor(Color.parseColor("#FFD1A738"));
        this.ia.setStyle(Style.FILL);
        this.ia.setStrokeWidth((float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F));
        this.ka = new Paint();
        this.ka.setAntiAlias(true);
        this.ka.setColor(Color.parseColor("#FFFFFFFF"));
        this.ka.setTypeface(Typeface.create("Huawei-Sans", NORMAL));
        this.ka.setTextSize((float)com.huawei.hms.audioeditor.ui.common.utils.a.a(9.0F));
        if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
            this.ka.setTextScaleX(-1.0F);
        } else {
            this.ka.setTextScaleX(1.0F);
        }

        this.la = new Paint();
        this.la.setAntiAlias(true);
        this.la.setColor(Color.parseColor("#FFFFFFFF"));
        this.la.setTypeface(Typeface.create("Huawei-Sans", NORMAL));
        this.la.setTextSize((float)com.huawei.hms.audioeditor.ui.common.utils.a.a(9.0F));
        if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
            this.la.setTextScaleX(-1.0F);
        } else {
            this.la.setTextScaleX(1.0F);
        }

        this.wa = new Paint();
        this.wa.setAntiAlias(true);
        this.wa.setColor(Color.parseColor("#66FFFFFF"));
        this.wa.setStyle(Style.FILL_AND_STROKE);
        this.ya = new PorterDuffXfermode(this.xa);
        this.za = new Paint();
        this.za.setColor(Color.parseColor("#40000000"));
        this.za.setStyle(Style.FILL_AND_STROKE);
        this.za.setStrokeWidth(5.0F);
        this.Aa = new Paint();
        this.Aa.setColor(Color.parseColor("#4ABEA1"));
        this.Aa.setStyle(Style.FILL_AND_STROKE);
        this.Aa.setStrokeWidth(5.0F);
        this.Ba = new Paint();
        this.Ba.setColor(Color.parseColor("#403A70"));
        this.Ba.setStyle(Style.FILL_AND_STROKE);
        this.Ba.setStrokeWidth(5.0F);
    }

    protected void onMeasure(int var1, int var2) {
        super.onMeasure(var1, var2);
        this.b(com.huawei.hms.audioeditor.ui.common.utils.a.a(48.0F));
    }

    public double j() {
        return (double)this.i() / d.a(super.l) * super.m - super.n - super.o - (double)super.f;
    }

    @SuppressLint({"DrawAllocation"})
    protected void onDraw(Canvas var1) {
        int var2 = com.huawei.hms.audioeditor.ui.common.utils.a.a(48.0F);
        RectF var3;
        float var5;
        double var6;
        float var10001;
        float var10002;
        float var18;
        if (this.y()) {

            var10001 = (float)(this.m() + super.a);
            var10002 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(2.0F);
            double var4 = (double)(this.m() + super.a);
            var3 = new RectF(var10001, var10002, (float) (this.j() + var4), (float) var2);
        } else {
            var3 = new RectF();
            var10001 = (float)(this.m() + super.a);
            var18 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(2.0F);
            var10002 = (var5 = (float)var2) * 0.25F + var18;
            var6 = (double)(this.m() + super.a);
            new RectF(var10001, var10002, (float) (this.j() + var6), var5 * 0.75F + (float) com.huawei.hms.audioeditor.ui.common.utils.a.a(0.0F));
        }

        long var19;
        if (this.sa && (var19 = super.r) != 0L) {
            this.ta = (var3.right - var3.left) / (float)var19;
        }

        super.onDraw(var1);
        this.a(var1, var3);
        HAEAudioAsset var14;
        float var15;
        int var20;
        int var21;
        double var22;
        String var24;
        float var27;
        float var34;
        float var39;
        int var47;
        float var48;
        Paint var49;
        int var52;
        if (this.y()) {
            this.b(var1, var3);
            this.a(var1, (float)var2);
            var47 = var20 = (var14 = (HAEAudioAsset)this.a()).getFadeInTimeMs();
            var21 = var14.getFadeOutTimeMs();
            if (var47 > 0 || var21 > 0) {
                var6 = this.j();
                Path var8;
                if ((var8 = this.ua) == null) {
                    this.ua = new Path();
                } else {
                    var8.reset();
                }

                if ((var8 = this.va) == null) {
                    this.va = new Path();
                } else {
                    var8.reset();
                }

                if (!((double)(var15 = (float)var14.getDuration()) < 0.1D)) {
                    BigDecimal var33;
                    var33 = new BigDecimal(String.valueOf(var20));
                    BigDecimal var9;
                    var9 = new BigDecimal(String.valueOf(var21));
                    BigDecimal var10;
                    var10 = new BigDecimal(String.valueOf(var15));
                    BigDecimal var11;
                    BigDecimal var50 = var11 = new BigDecimal(String.valueOf(var6));
                    BigDecimal var25 = var11.multiply(var33).divide(var10);
                    var50 = var50.multiply(var9).divide(var10);
                    var27 = (float)var25.setScale(5, 4).doubleValue();
                    float var7 = (float)var50.setScale(5, 4).doubleValue();
                    if (var20 > 0) {
                        this.ua.moveTo(var3.left, var3.top);
                        if ((float)var20 <= var15) {
                            this.ua.lineTo(var3.left + var27, var3.top);
                            var18 = var3.left;
                            this.ua.cubicTo(var27 * 0.6F + var18, (var34 = var3.bottom) * 0.2F, var27 * 0.4F + var18, var34 * 0.8F, var18, var34);
                        } else {
                            this.ua.lineTo(var3.right, var3.top);
                            this.ua.cubicTo((var18 = var3.right) * 0.6F, (var27 = var3.bottom) * 0.2F, var18 * 0.4F, var27 * 0.8F, var3.left, var27);
                        }

                        this.ua.close();
                    }

                    if (var21 > 0) {
                        this.va.moveTo(var3.right, var3.top);
                        if ((float)var21 <= var15) {
                            this.va.lineTo(var3.right - var7, var3.top);
                            this.va.cubicTo((var15 = var3.right) - var7 * 0.6F, (var18 = var3.bottom) * 0.2F, var15 - var7 * 0.4F, var18 * 0.8F, var15, var18);
                        } else {
                            this.va.lineTo(var3.left, var3.top);
                            this.va.cubicTo((var15 = var3.right) * 0.6F, (var18 = var3.bottom) * 0.2F, var15 * 0.4F, var18 * 0.8F, var15, var18);
                        }

                        this.va.close();
                    }

                    var1.save();
                    Path var10009 = new Path();
                    var10009.addRoundRect(var3, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), Direction.CCW);
                    var1.clipPath(var10009);
                    this.wa.setXfermode(this.ya);
                    var1.drawPath(this.ua, this.wa);
                    var1.drawPath(this.va, this.wa);
                    this.ua.reset();
                    this.va.reset();
                    var1.restore();
                }
            }

            this.ka.setColor(Color.parseColor("#FFFFFFFF"));
            if (this.a() != null && this.a() instanceof HAEAudioAsset) {
                if (this.ma == null) {
                    this.ma = BitmapFactory.decodeResource(this.pa.getResources(), drawable.icon_mini_music);
                }

                boolean var16;
                if ((var16 = ((HAEAudioAsset)this.a()).isSpaceRender()) && this.na == null) {
                    this.na = BitmapFactory.decodeResource(this.pa.getResources(), drawable.icon_mini_space_render);
                }

                var24 = ((HAEAudioAsset)this.a()).getAudioName();
                var52 = this.m() + super.a;
                var5 = (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F) + var52);
                var6 = this.j() - (double)super.a;
                if (var16) {
                    var6 -= (double)com.huawei.hms.audioeditor.ui.common.utils.a.a(20.0F);
                }

                if (com.huawei.hms.audioeditor.ui.common.utils.a.a(var24)) {
                    if (var16 && var6 > 0.0D) {
                        var1.drawBitmap(this.na, var5, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                    }
                } else {
                    var48 = var34 = this.ka.measureText(var24);
                    Rect var35;
                    var35 = new Rect();
                    this.ka.getTextBounds(var24, 0, var24.length(), var35);
                    if ((double)var48 >= var6) {
                        var49 = this.ka;
                        int var38 = var24.length();
                        var39 = (float)((int)var6);
                        var47 = var38 = var49.breakText(var24, 0, var38, true, var39, (float[])null);
                        var39 = 0.0F;
                        if (var47 < 1) {
                            this.oa = "";
                        } else {
                            StringBuilder var10005 = new StringBuilder();
                            this.oa = var10005.append(var24.substring(0, var38 - 1)).append("..").toString();
                            var1.drawBitmap(this.ma, var5, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                            var34 = (float)this.ma.getWidth();
                            var39 = this.ka.measureText(this.oa) + var34 + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(10.0F);
                        }

                        if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                            var1.drawText(this.oa, var5 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F) + (float)this.a(var24, this.ka), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F), this.ka);
                            if (var16 && var6 > 0.0D) {
                                var1.drawBitmap(this.na, var5 + var39 + (float)this.a(var24, this.ka), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                            }
                        } else {
                            var1.drawText(this.oa, var5 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F), this.ka);
                            if (var16 && var6 > 0.0D) {
                                var1.drawBitmap(this.na, var5 + var39, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                            }
                        }
                    } else if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                        var1.drawBitmap(this.ma, var5, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                        var1.drawRoundRect(var5 - 4.0F, (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) - 4), var5 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) + (float)this.a(var24, this.ka), (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) + this.ma.getHeight() + 4), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(2.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(2.0F), this.za);
                        var1.drawText(var24, var5 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F) + (float)this.a(var24, this.ka), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F), this.ka);
                        if (var16) {
                            var1.drawBitmap(this.na, var5 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(10.0F) + (float)this.a(var24, this.ka), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                        }
                    } else {
                        var1.drawBitmap(this.ma, var5, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                        var1.drawRoundRect(var5 - 4.0F, (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) - 4), var5 + var34 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) + this.ma.getHeight() + 4), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(2.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(2.0F), this.za);
                        var1.drawText(var24, var5 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F), this.ka);
                        if (var16) {
                            var1.drawBitmap(this.na, var5 + (float)this.ma.getWidth() + var34 + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(10.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.ka);
                        }
                    }
                }
            }
        } else {
            HAEAsset var17;
            if ((var17 = this.a()) != null && var17 instanceof HAEAudioAsset) {
                if (this.ma == null) {
                    this.ma = BitmapFactory.decodeResource(this.pa.getResources(), drawable.icon_mini_music);
                }

                var47 = this.m() + super.a;
                var15 = (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F) + var47);
                if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                    this.ka.setTextScaleX(-1.0F);
                } else {
                    this.ka.setTextScaleX(1.0F);
                }

                if (!com.huawei.hms.audioeditor.ui.common.utils.a.a(var24 = ((HAEAudioAsset)this.a()).getAudioName())) {
                    var48 = this.ka.measureText(var24);
                    var22 = this.j() - (double)super.a;
                    Bitmap var51;
                    if ((double)var48 >= var22) {
                        var49 = this.ka;
                        var21 = var24.length();
                        var27 = (float)((int)var22);
                        if ((var21 = var49.breakText(var24, 0, var21, true, var27, (float[])null)) < 1) {
                            this.oa = "";
                        } else {
                            StringBuilder var10003 = new StringBuilder();
                            this.oa = var10003.append(var24.substring(0, var21 - 1)).append("...").toString();
                            var51 = this.ma;
                            var5 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F);
                            var1.drawBitmap(var51, var15, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 2.0F, 5.0F, var5), this.ka);
                        }

                        String var53;
                        if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                            var53 = this.oa;
                            var10002 = var15 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F) + (float)this.a(var24, this.ka);
                            var15 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F);
                            var1.drawText(var53, var10002, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 2.0F, 5.0F, var15), this.ka);
                        } else {
                            var53 = this.oa;
                            var10002 = var15 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F);
                            var15 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F);
                            var1.drawText(var53, var10002, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 2.0F, 5.0F, var15), this.ka);
                        }
                    } else {
                        Rect var29;
                        var29 = new Rect();
                        this.ka.getTextBounds(var24, 0, var24.length(), var29);
                        this.ka.setColor(Color.parseColor("#B597FD"));
                        var51 = this.ma;
                        var5 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F);
                        var1.drawBitmap(var51, var15, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 2.0F, 5.0F, var5), this.ka);
                        if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                            var10002 = var15 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F) + (float)this.a(var24, this.ka);
                            var15 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F);
                            var1.drawText(var24, var10002, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 2.0F, 5.0F, var15), this.ka);
                        } else {
                            var10002 = var15 + (float)this.ma.getWidth() + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F);
                            var15 = (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F);
                            var1.drawText(var24, var10002, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 2.0F, 5.0F, var15), this.ka);
                        }
                    }
                }
            }
        }

        if (super.editPreviewViewModel.getLdUuid().getValue() == null || "".equals(super.editPreviewViewModel.getLdUuid().getValue())) {
            this.Da = new ArrayList();
            RequestParas var28;
            String var32;
            WaveTrackView.a var37;
            if (1 == (var28 = (var14 = (HAEAudioAsset)this.a()).getRequestParas()).getSurroundModule()) {
                switch(var28.getSurroundType()) {
                case 0:
                    var32 = this.pa.getResources().getString(string.sound_0);
                    break;
                case 1:
                    var32 = this.pa.getResources().getString(string.sound_1);
                    break;
                case 2:
                    var32 = this.pa.getResources().getString(string.sound_2);
                    break;
                case 3:
                    var32 = this.pa.getResources().getString(string.sound_3);
                    break;
                default:
                    var32 = "None";
                }

                var37 = new WaveTrackView.a(this.pa.getResources().getColor(color.bg_sound), var32);
                this.Da.add(var37);
            }

            WaveTrackView.a var40;
            if (var28.getLbaModule() == 1) {
                var40 = new WaveTrackView.a(this.pa.getResources().getColor(color.bg_style), this.pa.getResources().getString(string.heavy_bass));
                this.Da.add(var40);
            }

            if (var28.getEqModule() == 1) {
                var40 = new WaveTrackView.a(this.pa.getResources().getColor(color.bg_equilibrium), this.pa.getResources().getString(string.equilibrium));
                this.Da.add(var40);
            }

            if (!com.huawei.hms.audioeditor.ui.common.utils.a.c(var22 = (double)var14.getSoundType(), 0.0D)) {
                if (com.huawei.hms.audioeditor.ui.common.utils.a.c(var22, 0.75D)) {
                    var32 = this.getResources().getString(string.uncle);
                } else if (com.huawei.hms.audioeditor.ui.common.utils.a.c(var22, 0.550000011920929D)) {
                    var32 = this.getResources().getString(string.monsters);
                } else if (com.huawei.hms.audioeditor.ui.common.utils.a.c(var22, 1.7999999523162842D)) {
                    var32 = this.getResources().getString(string.lori);
                } else if (com.huawei.hms.audioeditor.ui.common.utils.a.c(var22, 0.6499999761581421D)) {
                    var32 = this.getResources().getString(string.male_voice);
                } else if (com.huawei.hms.audioeditor.ui.common.utils.a.c(var22, 1.440000057220459D)) {
                    var32 = this.getResources().getString(string.female_voice);
                } else {
                    var32 = "";
                }

                var37 = new WaveTrackView.a(this.getResources().getColor(color.bg_voice_change), var32);
                this.Da.add(var37);
            }

            if (var14.isReduceNoise()) {
                WaveTrackView.a var23;
                var23 = new WaveTrackView.a(this.pa.getResources().getColor(color.bg_reduce_noise), this.pa.getResources().getString(string.reduce_noise));
                this.Da.add(var23);
            }

            WaveTrackView.a var31;
            if (var28.getEtModule() == 1) {
                String var26;
                switch(var28.getEnvironmentType()) {
                case 0:
                    var26 = this.pa.getResources().getString(string.environment_gb);
                    break;
                case 1:
                    var26 = this.pa.getResources().getString(string.environment_tel);
                    break;
                case 2:
                    var26 = this.pa.getResources().getString(string.environment_sx);
                    break;
                case 3:
                    var26 = this.pa.getResources().getString(string.environment_cd);
                    break;
                default:
                    var26 = "无";
                }

                var31 = new WaveTrackView.a(this.pa.getResources().getColor(color.bg_environment), var26);
                this.Da.add(var31);
            }

            for(var2 = 0; var2 < this.Da.size(); ++var2) {
                ((WaveTrackView.a)this.Da.get(var2)).a(var2);
                var21 = (var31 = (WaveTrackView.a)this.Da.get(var2)).c();
                this.Aa.setColor(var31.a());
                if (this.a() != null && this.a() instanceof HAEAudioAsset) {
                    if (this.ma == null) {
                        this.ma = BitmapFactory.decodeResource(this.pa.getResources(), drawable.icon_mini_music);
                    }

                    var52 = this.m() + super.a;
                    var27 = (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F) + var52);
                    String var30 = var31.b();
                    var34 = this.la.measureText(var30);
                    if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                        var31.a((float)this.a(var30, this.la));
                        ((WaveTrackView.a)this.Da.get(var31.c())).a((float)this.a(var30, this.la));
                    } else {
                        var31.a(var34);
                        ((WaveTrackView.a)this.Da.get(var31.c())).a(var34);
                    }

                    var20 = var21 * 2;
                    var39 = var27 + (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) * var20);
                    float var42 = (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) - 4);
                    var42 = com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 3.0F, 5.0F, var42);
                    float var45 = var27 + (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) * (var20 + 1));

                    for(int var12 = 0; var12 <= var21; ++var12) {
                        var45 += ((WaveTrackView.a)this.Da.get(var12)).c;
                        if (var12 < var21) {
                            var39 += ((WaveTrackView.a)this.Da.get(var12)).c;
                        }
                    }

                    float var46 = (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) + this.ma.getHeight() + 4);
                    var46 = com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 3.0F, 5.0F, var46);
                    RectF var13;
                    var13 = new RectF(var39, var42, var45, var46);
                    if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                        var1.drawRoundRect(var13, var34 + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), var34 + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) + (float)this.a(var30, this.la), this.Aa);
                    } else {
                        var1.drawRoundRect(var13, var34 + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), var34 + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F), this.Aa);
                    }

                    Rect var43;
                    var43 = new Rect();
                    this.la.getTextBounds(var30, 0, var30.length(), var43);
                    var18 = var27 + (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(3.0F) + (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(6.0F) * var20);

                    for(int var44 = 0; var44 < var21; ++var44) {
                        var18 += ((WaveTrackView.a)this.Da.get(var44)).c;
                    }

                    if (com.huawei.hms.audioeditor.ui.common.utils.a.a()) {
                        var10002 = var18 + (float)this.a(var30, this.la);
                        var18 = (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F) + 4);
                        var1.drawText(var30, var10002, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 3.0F, 5.0F, var18), this.la);
                    } else {
                        var10002 = var18;
                        var18 = (float)(com.huawei.hms.audioeditor.ui.common.utils.a.a(12.0F) + 4);
                        var1.drawText(var30, var10002, com.huawei.hms.audioeditor.ui.p.a.a(var3.bottom, 3.0F, 5.0F, var18), this.la);
                    }
                }
            }
        }

    }

    protected void a(Canvas var1, RectF var2) {
        if (this.o().equals(super.editPreviewViewModel.getLdUuid().getValue())) {
            var1.drawRect(var2, this.fa);
        } else if (com.huawei.hms.audioeditor.ui.common.utils.a.a((String)super.editPreviewViewModel.getLdUuid().getValue()) || super.editPreviewViewModel.D().getValue() != null && this.a().getUuid().equals(super.editPreviewViewModel.D().getValue())) {
            var1.drawRoundRect(var2, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), this.fa);
        } else {
            var1.drawRoundRect(var2, (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), (float)com.huawei.hms.audioeditor.ui.common.utils.a.a(4.0F), this.Ba);
        }

    }

    public void a(boolean var1) {
        if (var1) {
            this.fa.setColor(Color.parseColor("#28FFFFFF"));
        } else {
            this.fa.setColor(Color.parseColor("#1AFFFFFF"));
        }

        this.invalidate();
    }

    protected void b(Canvas var1, RectF var2) {
        float var3 = var2.centerY();
        float var4 = var2.left;
        if (this.Ca) {
            double var5 = (double)var3;
            com.huawei.hms.audioeditor.ui.common.utils.a.d(0.95D, var5);
            com.huawei.hms.audioeditor.ui.common.utils.a.d(1.05D, var5);
            this.Ca = false;
        }

        if (this.sa) {
            this.Ea = this.m() + super.a;
        }

        if (super.K != null) {
            super.J.clear();
            super.J.addAll(super.K);
        }

        List var8;
        if ((var8 = super.J) != null && var8.size() > 0) {
            Iterator var9 = super.J.iterator();

            while(var9.hasNext()) {
                HAEAudioVolumeObject var6;
                if ((var6 = (HAEAudioVolumeObject)var9.next()) != null) {
                    float var7 = (float)this.Ea;
                    float var10001 = Math.max(var4, (float)(var6.getTime() - super.W) * this.ta + var7);
                    var1.drawLine(var10001, var3 - this.a(var6), var10001, var3 + this.a(var6), this.ga);
                }
            }

            var1.drawLine((float)this.Ea, var3, var2.right, var3, this.ga);
        }
    }

    protected void a(Canvas var1, float var2) {
        for(int var3 = 0; var3 < this.qa.size(); ++var3) {
            int var4 = super.a;
            float var10001 = (float)(this.m() + var4);
            float var5 = (Float)this.qa.get(var3);
            var1.drawPoint(var10001 + this.ta * var5, var2, this.ia);
        }

    }

    void a(long var1, int var3) {
        this.Fa = 0;
        this.sa = true;
        int var4;
        long var5;
        if ((var4 = (var5 = var1 - 0L) == 0L ? 0 : (var5 < 0L ? -1 : 1)) != 0) {
            if (var4 < 0) {
                if (var3 == 1 && -var1 > this.a().getTrimIn()) {
                    var1 = -this.a().getTrimIn();
                } else if (var3 == -1 && -var1 > this.a().getTrimOut()) {
                    var1 = -this.a().getTrimOut();
                }
            }

            this.n().a(this.a(), var1, var3);
        }
    }

    protected void a(int var1, int var2, MotionEvent var3) {
        if (var1 != 0 && (var1 <= 0 || !(this.j() - (double)var1 <= this.h()))) {
            if (var1 < 0 && this.j() - (double)var1 >= this.g()) {
                var1 = (int)(this.j() - this.g());
            }

            this.sa = false;
            this.Fa += var1;
            double var4;
            long var6 = (long)com.huawei.hms.audioeditor.ui.common.utils.a.d(d.a(this.d()), com.huawei.hms.audioeditor.ui.common.utils.a.b(var4 = (double)var1, this.e()));
            long var8 = (long)com.huawei.hms.audioeditor.ui.common.utils.a.d(d.a(this.d()), com.huawei.hms.audioeditor.ui.common.utils.a.b((double)this.Fa, this.e()));
            boolean var10;
            if (var2 == 0) {
                if (var6 < 0L && super.W + super.D + var6 < 0L) {
                    return;
                }

                var10 = var1 < 0;

                super.n += var4;
                if (super.F > 0 && Math.abs(this.m() - super.F) < super.E) {
                    return;
                }

                super.F = -1;
                this.a(var3);
                super.D = (long)com.huawei.hms.audioeditor.ui.common.utils.a.d(d.a(super.l), com.huawei.hms.audioeditor.ui.common.utils.a.b(super.n, super.m));
            } else {
                if (var6 < 0L && super.aa + super.D + var6 < 0L) {
                    return;
                }

                var10 = var1 > 0;

                super.o += var4;
                if (super.F > 0) {
                    var4 = (double)this.m();
                    if (Math.abs(this.j() + var4 - (double)super.F) < (double)super.E) {
                        return;
                    }
                }

                super.F = -1;
                this.a(var3);
                super.D = (long)com.huawei.hms.audioeditor.ui.common.utils.a.d(d.a(super.l), com.huawei.hms.audioeditor.ui.common.utils.a.b(super.o, super.m));
            }

            List var11;
            if ((var11 = super.K) != null) {
                var11.clear();
            }

            if (var2 == 0) {
                long var12;
                super.K = this.a(super.I, (var12 = super.W) + var8, var12 + super.r);
            } else {
                long var10003 = super.W;
                super.K = this.a(super.I, var10003, var10003 + super.r - var8);
            }

            this.a(var10, var2);
            this.r();
            this.post(this::invalidate);
        }
    }

    public void a(int var1) {
        super.l = var1;
    }

    public void a(HAEAudioAsset haeAudioAsset) {
        SmartLog.i("WaveTrack", "WaveTrackView setWaveAsset " + haeAudioAsset);
        super.speed = haeAudioAsset.getSpeed();
//        this.a(haeAudioAsset);
        this.ra[0] = false;
        super.W = (long) Util.divideScale((float) haeAudioAsset.getTrimIn(), super.speed, 5);
        super.aa = haeAudioAsset.getTrimOut();
        super.startTime = haeAudioAsset.getStartTime();
        super.r = haeAudioAsset.getDuration();
        this.b(haeAudioAsset.getOriginLength());
        super.I.clear();
        super.I.addAll(((HAEAudioAsset)this.a()).getAudioList());
        this.qa.clear();
        if (haeAudioAsset.getFootPrintList().size() > 0) {
            this.qa.addAll(haeAudioAsset.getFootPrintList());
        }

        this.a(super.g);
        this.s();
    }

    @SuppressLint("ClickableViewAccessibility")
    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getActionMasked() == 1) {
            super.editPreviewViewModel.b(1);
        }

        return super.onTouchEvent(motionEvent);
    }

    public void b(double var1) {
        super.b(var1);
        this.ra[0] = false;
    }

    public boolean y() {
        return com.huawei.hms.audioeditor.ui.common.utils.a.a((String)super.editPreviewViewModel.getLdUuid().getValue()) || this.a().getUuid().equals(super.editPreviewViewModel.getLdUuid().getValue()) || super.editPreviewViewModel.D().getValue() != null && this.a().getUuid().equals(super.editPreviewViewModel.D().getValue());
    }

    public static class a {
        private int a;
        private String b;
        private float c;
        private int d;

        public a(int var1, String var2) {
            this.a = var1;
            this.b = var2;
        }

        public int c() {
            return this.d;
        }

        public void a(int var1) {
            this.d = var1;
        }

        public int a() {
            return this.a;
        }

        public String b() {
            return this.b;
        }

        public void a(float var1) {
            this.c = var1;
        }
    }
}
